import java.util.Scanner;

/**
 * @author : niu niu
 * @version : 1.0.0
 * @date : 2023/3/27 20:37
 *  字符串反转
 *  公共字串计算
 */
public class Day20 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String str1 = scanner.nextLine();
        String str2 = scanner.nextLine();
        System.out.println(countPublicString(str1, str2));
//        System.out.println(reverse(str));

    }


    //---------------------------------------------
    private static int countPublicString(String str1, String str2) {
        char[] row = str1.toCharArray();
        char[] col = str2.toCharArray();

        int[][] dp = new int[str1.length()+1][str2.length()+1];
        int max = 0;
        for (int i = 1; i < str1.length() +1; i++) {
            for (int j = 1; j < str2.length()+1; j++) {
                if (row[i-1] == col[j-1]){
                    dp[i][j] = dp[i-1][j-1] +1 ;
                }
                if (dp[i][j] > max){
                    max = dp[i][j];
                }
            }
        }
        return max;
    }
    //---------------------------------------------
    private static String reverse(String str) {
        char[] ch = str.toCharArray();
        int left = 0;
        int right = ch.length-1;
        while (left<right){
            swap(ch,left,right);
            left++;
            right--;
        }

        return String.valueOf(ch);
    }

    private static void swap(char[] ch, int left, int right) {
        char tem = ch[left];
        ch[left] = ch[right];
        ch[right] =tem;
    }
}
